const mongoose = require('mongoose')
const moment = require('moment')

const imageSchema = new mongoose.Schema({
    title: {
        type: String,
        maxlength: 128,
        required: true
    },
    description: {
        type: String,
        maxlength: 1024
    },
    originalname: {
        type: String,
        maxlength: 128,
        required: true
    },
    filename: {
        type: String,
        maxlength: 128,
        required: true
    },
    likes: {
        type: Number,
        default: 0
    },
    views: {
        type: Number,
        default: 0
    }
    // datetime: {
    //     type: Date,
    //     default: Date.now,
    //     get: date => moment(date, "YYYY-MM-DD HH:mm:ss").fromNow()
    // }
}, { timestamps: true })

mongoose.model('Image', imageSchema, 'images')